import { Component, HostListener, OnDestroy, OnInit } from "@angular/core";
import { sjgzxinModuledatas } from "../pubcomponent/pageTitle.datas";
import { CommService } from "../comm-service";
import { MyhttpService } from "../myhttp.service";
import { FormBuilder, FormGroup } from "@angular/forms";
import { MyValidator } from "../myvalidator-util";
import { LocalStorageService } from "../local-storage-service";
import { FileItem, FileLikeObject, FileUploader, ParsedResponseHeaders } from "ng2-file-upload";

declare var $: any;

@Component({
  template: `
  <div class="all_bg paddingTop">
    <div class="">
      <div class="marginBottom">
      <ng-container *ngIf="actionobj1.length">
        <portlet-action class="actions" [o]="actionobj1" (outhander)="actionHander($event)"></portlet-action>
      </ng-container>
      </div>
      <div class="portlet-body">
        <div class="row">
          <div class="col-lg-12">
            <div class="tabbable-custom nav-justified">
              <ul class="nav nav-tabs nav-justified">
                <li class="active"><a href="#ztxx" data-toggle="tab" (click)="tabToggle('ztxx')">状态信息</a>
                  <!-- <div class="arrdowm"></div> -->
                </li>
                <li><a href="#glbqsbxx" data-toggle="tab" (click)="tabToggle('glbqsbxx')">关联电子标签</a>
                  <!-- <div class="arrdowm"></div> -->
                </li>
              </ul>
              <div class="tab-content">
                <!--状态信息-->
                <div class="tab-pane active" id="ztxx">
                  <div class="row">
                    <form class="form-horizontal" role="form">
                      <div class="col-lg-4 col-lg-offset-7">
                        <div class="form-group">
                          <label class="col-lg-3 control-label">手持终端id:</label>
                          <div class="col-lg-8">
                            <input type="text" class="form-control" name="id" [(ngModel)]="s_obj.id"/>
                          </div>
                        </div>
                      </div>
                      <div class="col-lg-1">
                        <button type="button" class="btn blue" (click)="inittable_zdsb_ztxx()">
                          <i class="fa fa-search"></i> 搜索
                        </button>
                      </div>
                    </form>
                  </div>
                  <div class="row">
                    <div class="col-lg-12" *ngIf="table_zdsb_ztxx">
                      <my-table [o]="table_zdsb_ztxx"></my-table>
                    </div>
                  </div>
                </div>
                <!--关联电子标签-->
                <div class="tab-pane" id="glbqsbxx">
                  <div class="row">
                    <form class="form-horizontal" role="form">
                      <div class="col-lg-4 col-lg-offset-3">
                        <div class="form-group">
                          <label class="col-lg-3 control-label">手持终端id:</label>
                          <div class="col-lg-8">
                            <input type="text" class="form-control" name="id" [(ngModel)]="s_obj_glxx.id"/>
                          </div>
                        </div>
                      </div>
                      <div class="col-lg-4">
                        <div class="form-group">
                          <label class="col-lg-5 control-label">是否关联电子标签：</label>
                          <div class="col-lg-7">
                            <select class="form-control" name="sfgldzbq" id="sfgldzbqSelect"
                                    [(ngModel)]="s_obj_glxx.sfgldzbq" (change)="inittable_zdsb_glbqsbxx()"></select>
                          </div>
                        </div>
                      </div>
                      <div class="col-lg-1">
                        <button class="btn blue" (click)="inittable_zdsb_glbqsbxx()">
                          <i class="fa fa-search"></i> 搜索
                        </button>
                      </div>
                    </form>
                  </div>
                  <div class="row">
                    <div class="col-lg-12" *ngIf="table_zdsb_glxx">
                      <my-table [o]="table_zdsb_glxx"></my-table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="xq_zdsbModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">详情</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-12" *ngIf="xqobj_zdsb">
                <xq-form [o]="xqobj_zdsb"></xq-form>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">确 定</button>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="add_zdsbModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">{{modaltitle}}</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="form-horizontal" role="form" [formGroup]="formgroup_zdsb">
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      终端名称：</label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="sczdmcCtr"/>
                      <div
                        *ngIf="formgroup_zdsb.get('sczdmcCtr').invalid&&formgroup_zdsb.get('sczdmcCtr').dirty">
                          <span *ngIf="formgroup_zdsb.hasError('myrequire','sczdmcCtr')">
                                <tool-tip [o]="formgroup_zdsb.getError('myrequire','sczdmcCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      终端ID：</label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="idCtr"/>
                      <div
                        *ngIf="formgroup_zdsb.get('idCtr').invalid&&formgroup_zdsb.get('idCtr').dirty">
                          <span *ngIf="formgroup_zdsb.hasError('myrequire','idCtr')">
                                <tool-tip [o]="formgroup_zdsb.getError('myrequire','idCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      序列号：
                    </label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="xlhCtr"/>
                      <div
                        *ngIf="formgroup_zdsb.get('xlhCtr').invalid&&formgroup_zdsb.get('xlhCtr').dirty">
                          <span *ngIf="formgroup_zdsb.hasError('myrequire','xlhCtr')">
                                <tool-tip [o]="formgroup_zdsb.getError('myrequire','xlhCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      型号：
                    </label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="xhCtr"/>
                      <div
                        *ngIf="formgroup_zdsb.get('xhCtr').invalid&&formgroup_zdsb.get('xhCtr').dirty">
                          <span *ngIf="formgroup_zdsb.hasError('myrequire','xhCtr')">
                                <tool-tip [o]="formgroup_zdsb.getError('myrequire','xhCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      手机号：
                    </label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="sjhmCtr"/>
                      <div
                        *ngIf="formgroup_zdsb.get('sjhmCtr').invalid&&formgroup_zdsb.get('sjhmCtr').dirty">
                          <span *ngIf="formgroup_zdsb.hasError('ismobile','sjhmCtr')">
                                <tool-tip [o]="formgroup_zdsb.getError('ismobile','sjhmCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
            <button type="button" class="btn btn-primary" (click)="addsure_zdsb()">确 定</button>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="gldzbq_Modal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog bigmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">关联电子标签</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-8" *ngIf="table_zdbq">
                <div class="row">
                  <div class="col-lg-12">
                    <my-table [o]="table_zdbq" (outhander)="tableHander($event)"></my-table>
                  </div>
                </div>
              </div>
              <div class="col-lg-4">
                <div class="cache_title xqheader">
                  <h4 style="float:left">已选电子标签</h4>
                  <div style="float:right;">
                    <a href="javascript:void(0)" style="color:#fff;" title="清空" (click)="removeAll_selectdzbq()"><i
                      class="fa fa-bank"></i> 清空</a>
                  </div>
                </div>
                <ul *ngIf="selectDzbqCache.length" class="cache_room">
                  <li *ngFor="let item of selectDzbqCache;index as index" class="cache_item"
                      (mouseenter)="showRemovebtn(item)"
                      (mouseleave)="hideRemovebtn(item)">
                    <div class="removeCachebtn" *ngIf="item.showremovecellbtn" (click)="removeCache(item,index)"><i
                      class="fa fa-minus-circle"></i></div>
                    {{item.id}}
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
            <button type="button" class="btn btn-primary" (click)="sure_gldzbq()">确 定</button>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="xq_kglbqsjbModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">试卷包信息</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-12" *ngIf="xqobj_sjbxx">
                <xq-form [o]="xqobj_sjbxx"></xq-form>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关 闭</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal fad" id="viewglxx_Modal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">关联试卷包信息</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-12">
                <table class="table table-bordered">
                  <thead>
                  <tr>
                    <th>试卷包名称</th>
                    <th>电子标签id</th>
                  </tr>
                  </thead>
                  <tbody *ngIf="glsjbxxList.length">
                  <tr *ngFor="let row of glsjbxxList">
                    <td>{{row.sjbmc}}</td>
                    <td>{{row.dzbqid}}</td>
                  </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal fad" id="pldr_Modal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">批量导入</h4>
          </div>
          <div class="modal-body">
            <form class="form-horizontal" role="form">
              <div class="row">
                <div class="col-lg-9">
                  <div class="form-group">
                    <label class="control-label col-lg-3">
                      <require-label></require-label>
                      文件:</label>
                    <div class="col-lg-9">
                      <input *ngIf="showUploader" class="form-control ngselectFileInput" type="file" ng2FileSelect
                             [uploader]="uploader"
                             (change)="selectedFileOnChanged($event)"/>
                      <div class="input-group selectFile">
                        <div class="input-icon">
                          <input class="form-control" type="text" name="filename" readonly
                                 [value]="nowfilename">
                        </div>
                        <span class="input-group-btn">
                          <button class="btn btn-success" type="button"><i class="fa fa-file"></i> 选择</button>
                  </span>
                      </div>
                      <div *ngIf="filewarnflag">
                        <span class="help-block text-danger">{{filewarntext}}</span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-3">
                  <label class="control-label text-danger">
                    <a href="dzbqpldr.xlsx" download="批量新增模板下载.xlsx">批量新增模板下载</a>
                  </label>
                </div>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
            <button type="button" class="btn btn-primary" (click)="pldrDone()">确 定</button>
          </div>
        </div>
      </div>
    </div>
    </div>
  `,
  styles: [
    ".cache_title{height: 40px;line-height: 40px;background-color:#32c5d2;text-align: center;color: #fff}",
    " .xqheader{height:40px;padding:0px 15px;border-bottom: 1px solid #e5e5e5;}",
    " .xqheader h4{font-size:14px;font-weight:600;}",
    ".cache_room{list-style: none;margin-bottom: 0px;max-height: 460px;overflow-y: auto}",
    ".cache_item{padding: 10px 5px;background-color: #ebf5ec;margin: 5px;position: relative}",
    ".ngselectFileInput{display: none}"
  ]
})
export class ZdsbglComponent implements OnInit, OnDestroy {
  pagetitleobj: any;
  userinfo: any;
  actionobj1: any[] = [];
  activetab: string = "ztxx";
  s_obj: any = {
    sfgldzbq: "",//1 --未关联  0 --已关联  ""--全部
    ksjhbh: "", // 状态信息的不传
    id: "" //手持终端id
  };
  table_zdsb_ztxx: any;
  s_obj_glxx: any = {
    sfgldzbq: "1",  //1 --未关联  0 --已关联  ""--全部
    ksjhbh: '',
    id: "" //手持终端id
  };
  selectDefaultField: any = {
    sfgldzbq: ''
  };
  table_zdsb_glxx: any;
  caozuo_zdsbbh: string;

  zdsb_btns: any[] = ["zdsb_add", "zdsb_refresh", "zdsb_removeN", "zdsb_dr"];
  zdsb_c_btns: any[] = ["edite_zdsb", "remove_zdsb", "xq_zdsb", "glkz_zdsb", "ckglxx_zdsb"];
  hascbtns: string[] = [];
  xqobj_zdsb: any;
  formgroup_zdsb: FormGroup;
  modaltitle: string = "";
  modalflag: string;
  editeFixField: any = {
    sfqy: ""
  };
  // 这个查询 后台已经过滤为关联试卷包的了
  s_obj_dzbq: any = {
    ksjhbh: "",
  }
  table_zdbq: any; // 电子标签表格
  selectDzbqCache: any[] = [];// 已经选择的要关联的电子标签缓存列表
  s_ksjhbh: string;
  xqobj_sjbxx: any;  // 电子标签表格中，试卷包信息详情
  glsjbxxList: any[] = [];
  uploader: FileUploader;
  nowfilename: string = "";
  nowfile: FileItem;
  filewarnflag: boolean = false;
  filewarntext: string = "";
  showUploader: boolean = true;

  /**
   * 初始化按钮
   */
  initactions(): void {
    // this.commservice.getroleBtns(this.zdsb_btns, this.zdsb_c_btns, this.userinfo.nowroleid, "tablezdsb", (hasportbtns, hastablebtns) => {
    //   this.actionobj1 = hasportbtns;
    //   this.hascbtns = hastablebtns;
    // });
    this.commservice.getroleBtns_not_permissions(this.zdsb_btns, this.zdsb_c_btns, "tablezdsb", (hasportbtns, hastablebtns) => {
      this.actionobj1 = hasportbtns;
      this.hascbtns = hastablebtns;
      console.log(this.actionobj1, this.hascbtns);

    });
  }

  /**
   * 按钮的处理回调
   * @param e
   */
  actionHander(e: any): void {
    const fromv = e.pfrom;
    const actiontype = e.type;
    if (fromv === "tablezdsb") {
      if (actiontype === "refresh") {
        // 刷新
        if (this.activetab == "ztxx") {
          this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
        } else {
          this.table_zdsb_glxx = Object.assign({}, this.table_zdsb_glxx);
        }
      } else if (actiontype === "add") {
        // 添加
        this.add_zdsb();
      } else if (actiontype == "removeN") {
        //批量删除
        const selectrows = $("#table_zdsb_ztxx").bootstrapTable("getSelections");
        if (selectrows.length == 0) {
          this.commservice.myswal("warning", "请选择删除的数据", "", "ts", null);
          return;
        }
        this.removeN_zdsb(selectrows);
      } else if (actiontype == "dr") {
        this.pldr();
      }
    }
  }

  /**
   * 批量删除
   * @param selectrows
   */
  removeN_zdsb(selectrows: any): void {
    this.commservice.myswal("warning", "确认删除?", "", "cz", () => {
      const sczdbhsv = selectrows.map((item) => {
        return item.sczdbh;
      });
      const url = "sjgz/jcsj/sczdsbsc";
      this.itservice.kwPtPost(url, {
        sczdbhs: sczdbhsv
      }).subscribe(resp => {
        this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
          if (arg1) {
            if (arg2) {
              this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
              this.commservice.myswal("success", resp, "", "ts", null);
            } else {
              this.commservice.myswal("warning", resp, "", "ts", null);
            }
          } else {
            this.removeN_zdsb(selectrows);
          }
        });
      })
    })
  }

  /**
   * 批量导入终端设备
   */
  pldr(): void {
    this.showUploader = false;
    this.nowfilename = "";
    this.nowfile = null;
    this.filewarnflag = false;
    setTimeout(() => {
      this.showUploader = true;
      setTimeout(() => {
        $("#pldr_Modal").find(".selectFile")[0].onclick = function () {
          $("#pldr_Modal").find(".ngselectFileInput").click();
        };
        $("#pldr_Modal").modal({
          keyboard: true,
          backdrop: "static"
        });
      }, 200)
    }, 200);
  }

  /**
   * 添加手持终端设备
   */
  add_zdsb(): void {
    this.modalflag = "add";
    this.modaltitle = "添加终端设备";
    this.formgroup_zdsb.reset();
    $("#add_zdsbModal").modal({
      keyboard: true,
      backdrop: "static"
    });
  }


  tabToggle(activeTab: string): void {
    this.activetab = activeTab;
    if (this.activetab == "ztxx") {
      this.s_obj.id = "";
      this.inittable_zdsb_ztxx();
    } else if (this.activetab == "glbqsbxx") {
      $("#sfgldzbqSelect").selectpicker("val", this.selectDefaultField.sfgldzbq);
      this.s_obj_glxx.sfgldzbq = this.selectDefaultField.sfgldzbq;
      this.s_obj_glxx.id = "";
      this.inittable_zdsb_glbqsbxx();
    }
  }


  /**
   * 手持终端设备---状态信息表格
   */
  inittable_zdsb_ztxx(): void {
    const that = this;
    this.table_zdsb_ztxx = {
      tableid: "table_zdsb_ztxx",
      url: "sjgz/jcsj/sczdsblb",
      reqobj: this.s_obj,
      sidePagination: "server",
      pageSize: 10,
      pageList: [10, 20, 30],
      total: "totalRows",
      rows: "sczdsbList",
      columns: [{
        checkbox: true,
        visible: true
      }, {
        title: "序号",
        field: 'ordernum',
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "终端名称",
        field: 'sczdmc',
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "终端ID",
        field: "id",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        }
      }, {
        title: "型号",
        field: "xh",
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        }
      }, {
        title: "手机号",
        field: "sjhm",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "序列号",
        field: "xlh",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "故障状态",
        field: "gzzt",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        },
        formatter: function (v) {
          let retstr: string = "";
          if (v == "0") {
            retstr = "正常";
          } else if (v == "1") {
            retstr = "异常";
          }
          return retstr;
        }
      }, {
        title: "是否启用",
        field: "sfqy",
        events: this.myevents,
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        },
        formatter: function (v) {
          let str = "";
          if (v === "1") {
            // 已启用
            str = "<span style='color: blue;font-size: 20px;cursor: pointer' class='toggle'><i class='fa fa-toggle-on' aria-hidden='true'></i></span>&nbsp;&nbsp;<span style='color: blue;font-size: 20px;'></span>";
          } else if (v == "0") {
            // 未启用
            str = "<span style='color:black;font-size: 20px;cursor: pointer' class='toggle'><i class='fa fa-toggle-off' aria-hidden='true'></i></span>";
          }
          return str;
        }
      }, {
        title: "在线状态",
        field: "zxzt",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        },
        formatter: function (v) {
          let retstr: string = "";
          if (v == "0") {
            retstr = "<span style='color: #1caf9a'><i class='fa fa-circle'></i></span>"
          } else if (v == "1") {
            retstr = "<span style='color: grey'><i class='fa fa-circle'></i></span>"
          }
          return retstr;
        }
      }, {
        title: "电量",
        field: "dl",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "操作",
        field: "sczdbh",
        events: this.myevents,
        formatter: function (v) {
          let str = "";
          if (that.hascbtns.indexOf("edite_zdsb") != -1) {
            str += "<button type='button' class='btn btn-xs btn-primary edite_zdsb'><i class='fa fa-pencil'></i> 编辑</button>";
          }
          if (that.hascbtns.indexOf("remove_zdsb") != -1) {
            str += "<button type='button' class='btn btn-xs btn-warning remove_zdsb'><i class='fa fa-trash'></i> 删除</button>";
          }
          if (that.hascbtns.indexOf("xq_zdsb") != -1) {
            str += "<button type='button' class='btn btn-xs btn-info xq_zdsb'><i class='fa fa-search'></i> 详情</button>";
          }
          return str;
        }
      }]
    };
    // this.table_zdsb_ztxx.pageSize = 50;
    // this.table_zdsb_ztxx.pageList = [50];
    // this.table_zdsb_ztxx.hiddenPageinfoLink = true;
    // this.table_zdsb_ztxx.paginationLoop = true;
    // this.table_zdsb_ztxx.paginationPreText = "<i class='fa fa-arrow-left'></i>上一页";
    // this.table_zdsb_ztxx.paginationNextText = "下一页<i class='fa fa-arrow-right'></i>";
    // this.table_zdsb_ztxx.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
    this.table_zdsb_ztxx.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
  }

  /**
   * 手持终端设备---关联电子标签设备表格
   */
  inittable_zdsb_glbqsbxx(): void {
    const that = this;
    this.table_zdsb_glxx = {
      tableid: "table_zdsb_glxx",
      url: "sjgz/jcsj/sczdsblb",
      reqobj: this.s_obj_glxx,
      sidePagination: "server",
      pageSize: 10,
      pageList: [10, 20, 30],
      total: "totalRows",
      rows: "sczdsbList",
      columns: [{
        checkbox: true,
        visible: false
      }, {
        title: "序号",
        field: 'ordernum',
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "终端名称",
        field: 'sczdmc',
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "终端ID",
        field: "id",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        }
      }, {
        title: "型号",
        field: "xh",
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        }
      }, {
        title: "手机号",
        field: "sjhm",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "序列号",
        field: "xlh",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "故障状态",
        field: "gzzt",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        },
        formatter: function (v) {
          let retstr: string = "";
          if (v == "0") {
            retstr = "正常";
          } else if (v == "1") {
            retstr = "异常";
          }
          return retstr;
        }
      }, {
        title: "在线状态",
        field: "zxzt",
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        },
        formatter: function (v) {
          let retstr: string = "";
          if (v == "0") {
            retstr = "<span style='color: #1caf9a'><i class='fa fa-circle'></i></span>"
          } else if (v == "1") {
            retstr = "<span style='color: grey'><i class='fa fa-circle'></i></span>"
          }
          return retstr;
        }
      }, {
        title: "电量",
        field: "dl",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "操作",
        field: "sczdbh",
        events: this.myevents,
        formatter: function (v) {
          let str = "";
          if (that.hascbtns.indexOf("glkz_zdsb") != -1) {
            if (that.s_obj_glxx.sfgldzbq == "0") {
              // 关联过的
              str += "<button type='button' class='btn btn-xs btn-warning jcgl_zdsb'><i class='fa fa-unlock'></i>  解除关联</button>";
            } else if (that.s_obj_glxx.sfgldzbq == "1") {
              // 未关联过的
              str += "<button type='button' class='btn btn-xs btn-primary gl_zdsb'><i class='fa fa-lock'></i>  关联电子标签</button>";
            }
          }
          if (that.hascbtns.indexOf("ckglxx_zdsb") != -1) {
            if (that.s_obj_glxx.sfgldzbq == "0") {
              str += "<button type='button' class='btn btn-xs btn-primary ckglxx_zdsb'><i class='fa fa-eye'></i>  查看关联信息</button>";
            }
          }
          return str;
        }
      }]
    };
    // this.table_zdsb_glxx.pageSize = 50;
    // this.table_zdsb_glxx.pageList = [50];
    // this.table_zdsb_glxx.hiddenPageinfoLink = true;
    // this.table_zdsb_glxx.paginationLoop = true;
    // this.table_zdsb_glxx.paginationPreText = "<i class='fa fa-arrow-left'></i>上一页";
    // this.table_zdsb_glxx.paginationNextText = "下一页<i class='fa fa-arrow-right'></i>";
    // this.table_zdsb_glxx.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
    this.table_zdsb_glxx.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
  }

  @HostListener("window:myevents", ["$event"])
  myevents = {
    "click .toggle": function (e, value, row, index) {
      // 启用状态改变
      if (value === "1") {
        this.upzdsbZt("0", row, index);
      } else {
        this.upzdsbZt("1", row, index);
      }
    }.bind(this),
    "click .edite_zdsb": function (e, value, row, index) {
      // 编辑
      this.caozuo_zdsbbh = value;
      this.edite_zdsb(row);
    }.bind(this),
    "click .remove_zdsb": function (e, value, row, index) {
      // 单条删除
      this.caozuo_zdsbbh = value;
      if (!this.caozuo_zdsbbh) {
        return
      }
      this.commservice.myswal("warning", "确定删除？", "", "cz", () => {
        this.removeDone_zdsb();
      });
    }.bind(this),
    "click .xq_zdsb": function (e, value, row, index) {
      // 详情
      this.caozuo_zdsbbh = value;
      this.xq_zdsb();
    }.bind(this),
    "click .jcgl_zdsb": function (e, value, row, index) {
      // 解除 关联的电子标签
      this.caozuo_zdsbbh = value;
      this.commservice.myswal("warning", "确定解除关联？", "", "cz", () => {
        this.unglzdbqsb();
      });
    }.bind(this),
    "click .gl_zdsb": function (e, value, row, index) {
      //关联电子标签
      this.caozuo_zdsbbh = value;
      this.gldzbqsb();
    }.bind(this),
    "click .infosjbxx": function (e, value, row, index) {
      // 选择关联的电子标签表格中， 试卷包的详细信息
      this.xqobj_sjbxx = {
        from: "zdsb_glbqsb_sjbxx",
        keyValue: {
          sjbsjxxList: value ? value : []
        }
      };
      $("#xq_kglbqsjbModal").modal({
        keyboard: true,
        backdrop: "static"
      });
    }.bind(this),
    "click .ckglxx_zdsb": function (e, value, row, index) {
      //查看关联信息  （ 终端绑定的电子标签）
      const sczdbhv = row.sczdbh;
      if (!sczdbhv) {
        return
      }
      this.viewglxx(sczdbhv);
    }.bind(this)
  }

  /**
   * 查看电子标签的关联信息（试卷包的信息）
   * @param {string} bh
   */
  viewglxx(bh: string): void {
    const url = "sjgz/jcsjgl/cxglsjbxx";
    this.itservice.kwPtPost(url, {
      ksjhbh: this.s_obj_glxx.ksjhbh,
      cxlx: "sczdsb",
      bh: bh
    }).subscribe(resp => {
      this.commservice.handResponse("get", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            const glsjbxxListv = resp.glsjbxxList ? resp.glsjbxxList : [];
            this.glsjbxxList = glsjbxxListv;
            $("#viewglxx_Modal").modal({
              keyboard: true,
              backdrop: "static"
            });
          }
        } else {
          this.viewglxx(bh);
        }
      });
    });
  }

  /**
   * 更改终端设备状态
   * @param {string} zdsbzt
   * @param row
   * @param index
   */
  upzdsbZt(zdsbzt: string, row: any, index): void {
    const url = "sjgz/jcsj/scdzSfqy";
    this.itservice.kwPtPost(url, {
      sfqy: zdsbzt,
      sblx: "sczdsb",
      sbbhs: [row.sczdbh]
    }).subscribe(resp => {
      this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.commservice.myswal("success", resp, "", "ts", null);
            $("#table_zdsb_ztxx").bootstrapTable("updateCell", { index: index, field: "sfqy", value: zdsbzt });
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.upzdsbZt(zdsbzt, row, index);
        }
      });
    })

    // const url = "sjgz/jcsj/sczdsbxg";
    // this.itservice.kwPtPost(url, {
    //   sczdbh: row.sczdbh,
    //   id: row.id,
    //   sczdmc: row.sczdmc,
    //   sjhm: row.sjhm,
    //   xlh: row.xlh,
    //   xh: row.xh,
    //   sfqy: zdsbzt
    // }).subscribe(resp => {
    //   this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
    //     if (arg1) {
    //       if (arg2) {
    //         this.commservice.myswal("success", resp, "", "ts", null);
    //         $("#table_zdsb_ztxx").bootstrapTable("updateCell", {index: index, field: "sfqy", value: zdsbzt});
    //       } else {
    //         this.commservice.myswal("warning", resp, "", "ts", null);
    //       }
    //     } else {
    //       this.upzdsbZt(zdsbzt, row, index);
    //     }
    //   });
    // });
  }

  /**
   * 单条删除，终端设备
   */
  removeDone_zdsb(): void {
    const url = "sjgz/jcsj/sczdsbsc";
    this.itservice.kwPtPost(url, {
      sczdbhs: [this.caozuo_zdsbbh]
    }).subscribe(resp => {
      this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.commservice.myswal("success", resp, "", "ts", null);
            this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.removeDone_zdsb();
        }
      });
    })
  }

  /**
   * 终端设备详情
   */
  xq_zdsb(): void {
    const url = "sjgz/jcsj/sczdsbxq";
    this.itservice.kwPtPost(url, {
      sczdbh: this.caozuo_zdsbbh
    }).subscribe(resp => {
      this.commservice.handResponse("get", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            resp.sfqymc = (resp.sfqy == "0") ? "未启用" : '已启用';
            this.xqobj_zdsb = {
              from: "zdsb",
              keyValue: resp
            };
            $("#xq_zdsbModal").modal({
              keyboard: true,
              backdrop: "static"
            });
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.xq_zdsb();
        }
      })
    })
  }

  /**
   * 关联电子标签设备
   */
  gldzbqsb(): void {
    this.table_zdbq = Object.assign({}, this.table_zdbq);
    this.selectDzbqCache.length = 0;
    $("#gldzbq_Modal").modal({
      keyboard: true,
      backdrop: "static"
    });
  }

  /**
   *关联电子标签设备  done
   */
  sure_gldzbq(): void {
    if (!this.caozuo_zdsbbh) {
      return
    }
    if (!this.selectDzbqCache.length) {
      this.commservice.myswal("warning", "未选择关联的电子标签", "", "ts", null);
      return
    }
    const dzbqbhsv = this.selectDzbqCache.map((item) => {
      return item.dzbqbh;
    });
    const url = "sjgz/jcsjgl/sczdGldzbq";
    this.itservice.kwPtPost(url, {
      sczdbh: this.caozuo_zdsbbh,
      dzbqbhs: dzbqbhsv,
      ksjhbh: this.s_ksjhbh
    }).subscribe(resp => {
      this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.commservice.myswal("success", resp, "", "ts", null);
            $("#gldzbq_Modal").modal("hide");
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.sure_gldzbq();
        }
      });
    })
  }

  /**
   * 解除关联电子标签设备
   */
  unglzdbqsb(): void {
    const url = "sjgz/jcsjgl/jcSczdbqgl";
    this.itservice.kwPtPost(url, {
      sczdbh: this.caozuo_zdsbbh,
      ksjhbh: this.s_ksjhbh
    }).subscribe(resp => {
      this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.commservice.myswal("success", resp, "", "ts", null);
            this.table_zdsb_glxx = Object.assign({}, this.table_zdsb_glxx);
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.unglzdbqsb();
        }
      });
    });
  }


  /**
   * 编辑手持终端设备
   */
  edite_zdsb(row: any): void {
    this.modalflag = "edite";
    this.modaltitle = "编辑终端设备";
    this.editeFixField.sfqy = row.sfqy;
    this.formgroup_zdsb.patchValue({
      sczdmcCtr: row.sczdmc,
      idCtr: row.id,
      sjhmCtr: row.sjhm,
      xlhCtr: row.xlh,
      xhCtr: row.xh,
    });

    $("#add_zdsbModal").modal({
      keyboard: true,
      backdrop: "static"
    });
  }

  createformgroup_zdsb(): void {
    this.formgroup_zdsb = this.fb.group({
      sczdmcCtr: ["", [this.myValidator.myrequired("终端名称")]],
      idCtr: ["", [this.myValidator.myrequired('终端ID')]],
      sjhmCtr: ["", [this.myValidator.isMobile(true)]],
      xlhCtr: ["", [this.myValidator.myrequired('序列号')]],
      xhCtr: ["", [this.myValidator.myrequired("型号")]]
    });
  }

  /**
   * 验证+ 添加/编辑
   */
  addsure_zdsb(): void {
    if (this.formgroup_zdsb.invalid) {
      const controls = this.formgroup_zdsb.controls;
      for (let path in controls) {
        controls[path].markAsDirty();
        controls[path].updateValueAndValidity();
      }
      return
    }
    const actionflag = this.modalflag;
    const formgroupv = this.formgroup_zdsb.getRawValue();
    const sczdmcv = this.commservice.removeSpace(true, formgroupv.sczdmcCtr);
    const idv = this.commservice.removeSpace(true, formgroupv.idCtr);
    const sjhmv = this.commservice.removeSpace(true, formgroupv.sjhmCtr);
    const xlhv = this.commservice.removeSpace(true, formgroupv.xlhCtr);
    const xhv = this.commservice.removeSpace(true, formgroupv.xhCtr);
    this.commservice.blockUI({
      boxed: true,
      message: "保存中...",
      zIndex: 10051,
      overlayColor: "#67809F"
    });
    if (actionflag == "add") {
      const url = "sjgz/jcsj/sczdsbxz";
      this.itservice.kwPtPost(url, {
        id: idv,
        sjhm: sjhmv,
        xlh: xlhv,
        xh: xhv,
        sczdmc: sczdmcv
      }).subscribe(resp => {
        this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
          if (arg1) {
            if (arg2) {
              this.commservice.myswal("success", resp, "", "ts", null);
              this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
              $("#add_zdsbModal").modal("hide");
              // 切换到 状态信息 tab
            } else {
              this.commservice.myswal("warning", resp, "", "ts", null);
            }
          } else {
            this.addsure_zdsb();
          }
        });
      });
    } else if (actionflag == "edite") {
      const url = "sjgz/jcsj/sczdsbxg";
      this.itservice.kwPtPost(url, {
        sczdbh: this.caozuo_zdsbbh,
        id: idv,
        sjhm: sjhmv,
        xlh: xlhv,
        xh: xhv,
        sczdmc: sczdmcv,
        sfqy: this.editeFixField.sfqy
      }).subscribe((resp) => {
        this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
          if (arg1) {
            if (arg2) {
              this.commservice.myswal("success", resp, "", "ts", null);
              this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
              $("#add_zdsbModal").modal("hide");
            } else {
              this.commservice.myswal("warning", resp, "", "ts", null);
            }
          } else {
            this.addsure_zdsb();
          }
        });
      })
    }
  }

  /**
   * 可以关联的电子标签表格 ，， 开启 且  关联了试卷包的
   */
  inittable_dzbq(): void {
    const that = this;
    this.table_zdbq = {
      tableid: "table_zdbq",
      url: "sjgz/jcsjsczdgl/gldzbqsjxxlb",
      reqobj: this.s_obj_dzbq,
      sidePagination: "server",
      pageSize: 10,
      pageList: [10, 20, 30],
      total: "totalRows",
      rows: "ygldzbqsbList",
      height: 450,
      columns: [{
        checkbox: true
      }, {
        title: "标签ID",
        field: "id",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "型号",
        field: "xh",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "试卷包名称",
        field: "sjbsjxxList",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        },
        events: this.myevents,
        formatter: function (v, row) {
          let retstr: string = "";
          // let kmlist: any[] = [];
          // if (v && v.length) {
          //   kmlist = v.map((item) => {
          //     return item.kmmc
          //   });
          // }
          // if (kmlist.length) {
          //   let kmstr: string = kmlist.join(";");
          //   kmstr = that.commservice.showTenchart(kmstr, 10);
          //   retstr += "<span>" + kmstr + "</span>";
          // }
          if (v && v.length) {
            retstr += "<span>" + row.glsjbmc + "</span>";
            retstr += "&nbsp;&nbsp;<button  type='button' class='btn btn-xs btn-primary infosjbxx'><i class='fa fa-search'></i>试卷包详情</button>"
          } else {
            retstr += "<span>未关联试卷包</span>";
          }
          return retstr;
        }
      }]
    };
    // this.table_zdbq.pageSize = 50;
    // this.table_zdbq.pageList = [50];
    // this.table_zdbq.hiddenPageinfoLink = true;
    // this.table_zdbq.paginationLoop = true;
    // this.table_zdbq.paginationPreText = "<i class='fa fa-arrow-left'></i>上一页";
    // this.table_zdbq.paginationNextText = "下一页<i class='fa fa-arrow-right'></i>";
    // this.table_zdbq.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
    this.table_zdbq.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 110;
  }

  tableHander(e: any): void {
    const tableid = e.tableid;
    const caozuo = e.caozuo;
    const row = e.row;
    switch (tableid) {
      case "table_zdbq":
        if (caozuo === "onCheck") {
          this.selectDzbqCache = this.selectDzbqCache.concat(row);
          this.selectDzbqCache = this.commservice.fliterobjRepeat(this.selectDzbqCache, "dzbqbh");
        } else if (caozuo === "onUncheck") {
          const del_dzbqbh = row.dzbqbh;
          for (let i = 0; i < this.selectDzbqCache.length; i++) {
            if (this.selectDzbqCache[i].dzbqbh == del_dzbqbh) {
              this.selectDzbqCache.splice(i, 1);
              break;
            }
          }
        } else if (caozuo === "onCheckAll") {
          this.selectDzbqCache = this.selectDzbqCache.concat(row);
          this.selectDzbqCache = this.commservice.fliterobjRepeat(this.selectDzbqCache, "dzbqbh");
        } else if (caozuo === "onUncheckAll") {
          //客户端分页，所有数据， 服务端分页，当前页的数据
          const selectrow = $("#table_zdbq").bootstrapTable("getData");
          const uncheckbhlist = selectrow.map((item) => {
            return item.dzbqbh;
          });
          this.selectDzbqCache = this.selectDzbqCache.filter((item) => {
            const dzbqbhv = item.dzbqbh;
            return uncheckbhlist.indexOf(dzbqbhv) == -1;
          });
        } else if (caozuo == "onPostBody") {
          // 根据右侧已经选择的数据，在切换页面的时候，吧当前页面的数据，给够选上
          const cachebhlist = this.selectDzbqCache.map((item) => {
            return item.dzbqbh;
          });
          $("#table_zdbq").bootstrapTable("checkBy", { field: "dzbqbh", values: cachebhlist });
        }
        break;
    }
  }

  /**
   * 清空选择的电子标签
   */
  removeAll_selectdzbq(): void {
    this.selectDzbqCache.length = 0;
    $("#table_zdbq").bootstrapTable("uncheckAll");
  }

  /**
   * 删除某一个选中的电子标签
   * @param obj
   */
  removeCache(obj: any, index: number): void {
    this.selectDzbqCache.splice(index, 1);
    //左侧表格勾选去掉
    $("#table_zdbq").bootstrapTable("uncheckBy", { field: "dzbqbh", values: [obj.dzbqbh] });
  }

  showRemovebtn(obj: any): void {
    obj.showremovecellbtn = true;
  }

  hideRemovebtn(obj: any): void {
    obj.showremovecellbtn = false;
  }


  /**
   * 手持终端设备-关联电子标签搜索表单
   */
  createsearchForm_glxx(): void {
    const sfgldzbqdataList = [{
      code: "1",
      name: '未关联'
    }, {
      code: "0",
      name: "已关联"
    }];
    $("#sfgldzbqSelect").empty();
    let str: string = "";
    sfgldzbqdataList.forEach((item) => {
      str += "<option value='" + item.code + "'>" + item.name + "</option>";
    });
    $("#sfgldzbqSelect").append(str);
    $("#sfgldzbqSelect").selectpicker({
      size: 5
    });
    this.selectDefaultField.sfgldzbq = sfgldzbqdataList[0].code;
  }

  /**
   * 获取用户信息
   */
  getuserinfo(): void {
    this.commservice.getUserinfo((info) => {
      this.userinfo = info;
      this.initactions(); //用户按钮权限
    });
  }

  initUploader(): void {
    // const filealias = "tysjdrwj";
    this.uploader = new FileUploader({
      url: `${this.commservice.uploadFileurl}sjgz/jcsj/sczdsbplxz`,
      method: "POST",
      // itemAlias: filealias,
      autoUpload: false,//选择文件后，自动上传
    });
    const pubheaderparams1 = this.commservice.getpubheaderParams1(null);
    const pubheaderparams2 = this.commservice.getpubheaderParams2();
    this.uploader.setOptions({
      headers: [{
        name: "xc_client_sessionid",
        value: pubheaderparams1.signkey
      }, {
        name: "Content-Signature",
        value: pubheaderparams1.signreqobj
      }, {
        name: 'xc_sso_sessionid',
        value: pubheaderparams2.access_token
      }, {
        name: "Authorization",
        value: pubheaderparams2.Authorization
      }],
      //allowedFileType: this.o.allowedFileType,
    });
  }

  initUploaderEvents() {
    this.uploader.onBuildItemForm = this.buildItemForm.bind(this);
    this.uploader.onAfterAddingFile = this.afterAddFile.bind(this);
    this.uploader.onWhenAddingFileFailed = this.whenAddFileFailed.bind(this);
    this.uploader.onProgressItem = this.onProgress.bind(this);
    this.uploader.onSuccessItem = this.successItem.bind(this);
  }

  buildItemForm(fileItem: FileItem, form: any): void {

  }

  selectedFileOnChanged(e: any): void {

  }

  afterAddFile(file: FileItem): void {
    // 对选择的dbf文件，做严格控制
    const filename = file.file.name;
    this.filewarnflag = false;
    this.filewarntext = "";
    this.nowfile = file;
    this.nowfilename = filename;
  }

  /**
   * 选择文件失败的回调
   * @param {FileLikeObject} item
   * @param filter
   * @param options
   */
  whenAddFileFailed(item: FileLikeObject, filter: any, options: any): void {
    // this.filewarnflag = true;
    // this.filewarntext = "文件格式不正确";
  }

  /**
   * 上传进度
   * @param {FileItem} fileItem  上传的文件
   * @param progress     该文件的上传进度
   * @returns {any}
   */
  onProgress(fileItem: FileItem, progress: any): any {

  }

  pldrDone(): void {
    if (!this.nowfile) {
      this.filewarnflag = true;
      this.filewarntext = "请选择导入数据文件";
      return
    }
    this.filewarnflag = false;
    this.filewarntext = "";

    this.commservice.myswal("warning", "确定导入文件内容?", "", "cz", () => {
      this.commservice.blockUI({
        boxed: true,
        message: "数据导入中...",
        zIndex: 10051,
        overlayColor: "#67809F"
      });
      this.uploader.uploadItem(this.nowfile);
    });
  }

  /**
   * 上传成功后 的回调
   * @param {FileItem} item
   * @param {string} response
   * @param {number} status
   * @param {ParsedResponseHeaders} headers
   */
  successItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): void {
    if (status == 200) {
      const respbody = JSON.parse(response);
      const ywcode = respbody.code; // 业务接口code 【8001(signkey 失效)】,【 200】【其他的失败直接抛出 message】
      const ywmsg = respbody.message; // 业务接口提示信息
      const ywresult = respbody.result;// 业务接口返回的数据
      if (ywcode == 200) {
        this.commservice.unblockUI(false);
        $("#pldr_Modal").modal("hide");
        this.table_zdsb_ztxx = Object.assign({}, this.table_zdsb_ztxx);
      } else {
        this.commservice.unblockUI(false);
        this.commservice.myswal("warning", ywmsg, "", "ts", null);
      }
    } else {
      // 上传文件后获取服务器返回的数据错误
      this.commservice.unblockUI(false);
      this.commservice.myswal("warning", "导入出错", "", "ts", null);
    }
  }

  constructor(private commservice: CommService,
    private itservice: MyhttpService,
    private fb: FormBuilder,
    private myValidator: MyValidator,
    private localstorage: LocalStorageService) {
  }

  ngOnInit() {
    this.pagetitleobj = sjgzxinModuledatas.zdsbgl;
    this.s_ksjhbh = this.localstorage.get("hksjh");
    this.s_obj_glxx.ksjhbh = this.s_ksjhbh;
    this.getuserinfo();
    this.inittable_zdsb_ztxx();
    this.createsearchForm_glxx();
    this.createformgroup_zdsb();
    // 关联电子标签
    this.s_obj_dzbq.ksjhbh = this.s_ksjhbh;
    this.inittable_dzbq();
    this.initUploader();
    this.initUploaderEvents();
  }

  ngOnDestroy() {

  }

}
